<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    南京地铁线路：
    <select name="startL" id="s1">
        <option value="0">--请选择--</option>
        <option value="L1">1号线</option>
        <option value="L2">2号线</option>
        <option value="L3">3号线</option>
        <option value="L4">4号线</option>
        <option value="L10">10号线</option>
        <option value="LS1">s1号线</option>
        <option value="LS3">s3号线</option>
        <option value="LS6">s6号线</option>
        <option value="LS7">s7号线</option>
        <option value="LS8">s8号线</option>
        <option value="LS9">s9号线</option>
    </select>
    <select name="startLocation" id="s2">
        <option value="1" selected>--请选择--</option>
    </select>
    <!-- <ul id="u1">

    </ul> -->




    <script src="./ajax.js"></script>
    <script>
        let s1Obj=document.querySelector('#s1');
        let s2Obj=document.querySelector('#s2');
        // var ID='';
        s1Obj.onchange=()=>{
            get('https://www.njmetro.com.cn/njdtweb/portal/get-stationList.do',
            `reLineId=${s1Obj.value}`,
            res=>{
                    s2Obj.innerHTML='';
                    if(Array.isArray(res.stationList) && res.stationList){
                        res.stationList.forEach((item)=>{
                            let optionObj=document.createElement('option');
                            optionObj.label=item.stationName;
                            document.querySelector('#s2').appendChild(optionObj);
                        })
                    }
                },
            null,
            'JSON'
            )
        }

    </script>
</body>
</html>